<@>layout("/common/default.html"){
<div class="x-nav">
    <span class="layui-breadcrumb">
        <a href="">首页</a>
        <span lay-separator="">/</span>
        <a href="">委托单位</a>
    </span>
    <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right" href="javascript:location.replace(location.href);" title="刷新">
        <i class="layui-icon" style="line-height:30px">ဂ</i>
    </a>
</div>
<div class="x-body">
    <div class="layui-row">
        <div class="layui-form layui-col-md12 x-so">
            <input id="name" type="text" name="name" placeholder="委托单名称" autocomplete="off" class="layui-input">
            <button class="layui-btn" onclick="doSearch();"><i class="layui-icon">&#xe615;</i></button>
            <button class="layui-btn" onclick="x_admin_show('添加角色','${ctxPath}/orders/add',600,800)"><i
                    class="layui-icon"></i>添加
            </button>
        </div>
    </div>
    <div class="layui-row layui-col-space15">
        <table class="layui-table"
               lay-data="{id:'orders-list', url:'${ctxPath}/ajax/orders/list', page:true,request: {pageName: 'page' ,limitName: 'rows'} }"
               lay-filter="orders-list" >
            <thead>
            <tr>
                <th lay-data="{field:'index', width:80, templet: '#table-index'}">序号</th>
                <th lay-data="{field:'name', width:150}">委托单位</th>
                <th lay-data="{field:'number', width:200}">委托单编号</th>
                <th lay-data="{field:'createTimeStr', width:280, sort:true}">创建时间</th>
                <th lay-data="{field:'createUserName', width:200}">创建人</th>
                <th lay-data="{field:'id', toolbar: '#toolbar',fixed:'right',width:200}">操作</th>
            </tr>
            </thead>
        </table>
    </div>

    <script type="text/html" id="toolbar">
        <a class="layui-btn layui-btn-xs" lay-event="joinGroup">进入聊天室</a>
    </script>

    <script type="text/html" id="role-state">
    </script>

    <script type="text/html" id="table-index">
        {{d.LAY_TABLE_INDEX + 1}}
    </script>
</div>
<script>
    $(function () {
        layui.use('table', function () {
            var table = layui.table;
            table.on('tool(orders-list)', function (obj) { //注：tool是工具条事件名，test是table原始容器的属性 lay-filter="对应的值"
                var data = obj.data; //获得当前行数据
                var layEvent = obj.event; //获得 lay-event 对应的值（也可以是表头的 event 参数对应的值）

                //进入聊天室
                if (layEvent === 'joinGroup') {
                    window.location.href ='${ctxPath}/layim/orders/joinGroup?id=' + data.id +'&number='+data.number;
                }
            });
        });
    });

    //搜索
    function doSearch() {
        layui.use('table', function () {
            var table = layui.table;
            table.reload('orders-list', {
                url: '${ctxPath}/ajax/orders/list',
                where: {
                    name: $('#name').val()
                }//设定异步数据接口的额外参数
            });
        });
    }
</script>
<@>}